<%@page import="java.sql.*" %>

<%@ page import="com.hline.kbcss.MyDriver"%>

<%//String uname=request.getParameter("uname");
 //System.out.println(uname);
 String uname=(String)session.getAttribute("uname");
 System.out.println("***************"+uname);
 if(uname==""||uname==null)
 {
	response.sendRedirect("userreg.jsp?message=<p align=center><font color=red style=font-family:regular size=3>username should not be null...</font></p>");
 }
 else
 {
		try
		{
			System.out.println("we are in check availability of try block");
			
			Statement stmt=MyDriver.getConnection("READ");
			String str="Select username from user";
			
			ResultSet rs=stmt.executeQuery(str);
			
			while(rs.next())
			{	
				String name=rs.getString(1);
				System.out.println(name);

				if(uname.equals(name))
				{
					response.sendRedirect("userreg.jsp?message=<p align=center><font color=red style=font-family:regular size=3>username is not available...</font></p>");
				}
				
			}
			//session.setAttribute("username",uname);
			response.sendRedirect("userreg.jsp?uname="+uname+"&message=<p align=center><font color=green style=font-family:regular size=3>username is available...</font></p>");
			
				
		}catch(Exception e)
		{
			System.out.println(e);
		}
 }
		%>